<?php

namespace App\Controller;

use App\Algorithm\ScheduleAlgorithm;
use App\Constants\ErrorCode;
use App\Controller\Api\BaseController;
use App\Controller\Ws\ServerController;
use App\Model\ConsultantDatum;
use App\Model\Country;
use App\Model\User;
use App\Model\WorkDate;
use App\Model\WorkReservation;
use App\Service\MobileSmsService;
use App\Service\TalkService;
use App\Support\WebSocket;
use App\Talk\Agora;
use App\Talk\Easemob;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\AutoController;
use Hyperf\HttpServer\Annotation\RequestMapping;
use Hyperf\HttpServer\Contract\RequestInterface;


/**
 * @AutoController()
 */
class TestController extends BaseController
{

    /**
     * @Inject()
     * @var ServerController
     */
    public $server;


    /**
     * @Inject()
     * @var WebSocket
     */
    public $websocket;


    /**
     * @Inject()
     * @var TalkService
     */
    public $talkService;


    /**
     * @Inject()
     * @var MobileSmsService
     */
    public $mobileSmsService;


    /**
     * @Inject()
     * @var ScheduleAlgorithm
     */
    public $scheduleAlgorithm;

    /**
     * @Inject()
     * @var Easemob
     */
    public $easemob;


    /**
     * @Inject()
     * @var Agora
     */
    public $agora;


    public function test(RequestInterface $request)
    {

//        $this->


    }


    /**
     *
     * @return void
     */
    public function wsMessageTest(RequestInterface $request)
    {

        $fd = $request->post('fd');
        $data = [
            'event' => $request->post('event', 'test'),
            'content' => [
                'message' => $request->post('message', 'test-message'),
                'uid' => intval($this->websocket->getUidByFd($fd)),
                'fd' => intval($fd)
            ]
        ];

        return $this->server->send($fd, $data);


    }


    public function cleanRedis(RequestInterface $request)
    {


        return cache()->clear();

    }

}
